#include "Sprite.h" 


Sprite::Sprite() {
	speed_x=0;
	speed_y=0;

	bottomBase.offset=5;
	bottomBase.length=20;
}

void Sprite::init() {
	
	relativeMove(speed_x, speed_y);
	
}

void Sprite::goRight() {
	speed_x=2;
}

void Sprite::goLeft() {
	speed_x=-2;
}


void Sprite::stop() {
	speed_x=0;
}

void Sprite::move(int x, int y) {

	Image::move(x, y);


	COLLISIONINFO collide;

	if (parentLayer!=NULL) {
		parentLayer->checkFutureCollisions(this, &collide);

		if (collide.bottom==true && speed_y>0)
			speed_y=0;
	}

}

void Sprite::jump() {
	speed_y=-5;
}

void Sprite::relativeMove(int x, int y) {

	left+=x;
	top+=y;


	COLLISIONINFO collide;

	if (parentLayer!=NULL) {
		parentLayer->checkFutureCollisions(this, &collide);

		if (collide.bottom==true && speed_y>0) {
			speed_y=0;
			relativeMove(0, collide.distanceY);
		}

	}


} // Fin fu





//----------------------

void Pelota::move(int x, int y) {

	Image::move(x, y);


	COLLISIONINFO collide;

	if (parentLayer!=NULL) {
		parentLayer->checkFutureCollisions(this, &collide);

		if (collide.bottom==true)
			speed_y=-speed_y;
	}

}

void Pelota::relativeMove(int x, int y) {

	left+=x;
	top+=y;


	COLLISIONINFO collide;

	if (parentLayer!=NULL) {
		parentLayer->checkFutureCollisions(this, &collide);

		if (collide.bottom==true)
			speed_y=-speed_y;
	}

}

void Pelota::init() {
	
	relativeMove(speed_x, speed_y);
	
}